package com.boco.raptor.subsystem.netadjust.action;

import javax.servlet.http.HttpServletRequest;
import com.boco.transnms.server.bo.base.BoName;
import com.boco.raptor.subsystem.attempx.server.bo.AttempXWfGenericBO;
import com.boco.transnms.common.dto.base.BoActionContext;
import com.boco.transnms.common.dto.workflow.WfIdHref;
import java.util.List;

public class NetAdjustAttachAction {
    public NetAdjustAttachAction() {
    }

    public WfIdHref[] getAttachfiles(HttpServletRequest request,String sheetId){
        WfIdHref[] attachOutlines = new WfIdHref[0];
        try{
            BoActionContext dbContext = new BoActionContext();
            List attachIds = getGenericBO().getAttachIds(dbContext,sheetId);
            if(attachIds != null){
                String[] ids = new String[attachIds.size()];
                for(int i = 0; i < attachIds.size(); i++){
                    ids[i] = (String)attachIds.get(i);
                }
                attachOutlines = getGenericBO().getAttachOutlines(dbContext,ids);
            }
        }catch(Exception ex){

        }
        return attachOutlines;
    }

    public String delAttachfile(HttpServletRequest request,String[] attachIds){
        String sReturn = "";
        BoActionContext dbContext = new BoActionContext();

        try{
            for(int i = 0; i < attachIds.length; i++){
                String attachId = attachIds[i];
                getGenericBO().delAttachFile(dbContext, attachId);
            }
        }catch(Exception ex){
            sReturn =  ex.getMessage();
        }
        return sReturn;
    }

    private AttempXWfGenericBO getGenericBO(){
        AttempXWfGenericBO rtn = new AttempXWfGenericBO(BoName.WfGenericBO);
        return rtn;
    }
}
